﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using MS.InformationManagement.Support.Constants;

namespace MS.InformationManagement.BLL.AdminAnulaciones
{
    public class AdminAnulaciones
    {
        public static List<SPListItem> GetItemsSolicitudAnulados(int pageIndex, int pageSize, out int totalRecords)
        {
            SPQuery query = new SPQuery();
            int startingPosition = pageIndex * pageSize;
            query.Query = string.Format("<Where><Eq><FieldRef Name='" + CustomSiteColumns.FIELD_SOLICITUD_ANULACION_ESTADO + "' /><Value Type='Choice'>Pendiente</Value></Eq></Where>");
            SPListItemCollection items = SPContext.Current.Web.Lists[GlobalConstants.LIST_SOLICITUD_ANULADOS].GetItems(query);
            if (items == null || items.Count == 0)
            {
                totalRecords = 0;
                return null;
            }

            totalRecords = items.Count;
            return items.Cast<SPListItem>().Skip(startingPosition).Take(pageSize).ToList();
        }
    }
}
